<?php
include_once('class/autoload.php'); // pour inclure nos classes
include_once('class/config.inc.php');
$site = new page_securisee('accueil');
if (utilCoTypeC($_SESSION['identifiant']) == 1){
if(isset($_POST['idPrat']))
{
	$idPrat=$_POST['idPrat'];
}
else{
	$idPrat=$_POST['idPratEdit'];
	//Si on a cliqué sur supprimer licence
	if(isset($_POST['Del'])){
		supp_Lic($_POST['idPratEdit'], $_POST['idLic']);
	}
	//Si on a cliqué sur ajouter licence
	else if(isset($_POST['Aj'])){
		ajout_Lic($_POST['idPratEdit'], $_POST['typeLic']);
	}
	//Si on a cliqué sur modifier le compte
	else if(isset($_POST['Modif'])){ 
		modif_Prat($_POST['idPratEdit'] ,$_POST['nomPratEdit'], $_POST['prenomPratEdit'], $_POST['adeliPratEdit'], $_POST['clePratEdit'], $_POST['datePratEdit']);
		//Pour mettre à jour le quota de SMS, décommenter
		//setQuota($_POST['idPratEdit'],$_POST['quotaSmsPratEdit']);
	}
	//Si on a cliqué sur supprimer le compte
	else if(isset($_POST['DelAll'])){
		supp_Prat($_POST['idPratEdit']); 
	}
	//Si on a cliqué sur modifier licence
	else if(isset($_POST['ModifLic'])){
		modif_Lic($_POST['idPratEdit'], $_POST['idLic'], $_POST['dateLicEdit']);
	}
}
$site->corps = 
'<form method="post" action="editClients.php"/>
    <h2 class="form-signin-heading">Edition de client</h2>
		<table class="table table-striped">
  			<thead>
  				<tr>
  					<th>#</th>
  					<th>Nom</th>
  					<th>Pr&eacutenom</th>
					<!--<th>Quota SMS</th>-->
  				</tr>
  			</thead>
  			<tbody>
  				<tr>
  					'.edit_praticiens_info($idPrat).'
  				</tr>
  			</tbody>
  		</table>
  		<br />
  		<table class="table table-striped">
  			<thead>
  				<tr>
  					<th>N&deg Ad&eacuteli</th>
  					<th>Cl&eacute Pyxvital</th>
  					<th>Date de fin (facultative)</th>
  					<th>&nbsp;</th>
  				</tr>
  			</thead>
  			<tbody>
  				<tr>
  					'.edit_praticiens_adeli($idPrat).'
  				</tr>
  			</tbody>
  		</table>
  		<br />
		<div align="center">
			<button type="submit" name="Modif" class="btn btn-primary">Modifier le compte client</button>
			<button type="submit" name="DelAll" class="btn btn-danger">Supprimer le compte client</button>
		</div>	
		<br /><hr><br /><br />
	    <table class="table table-striped">
	        <thead>
	        	<tr>
	        		<th>#</th>
	        		<th>Licences</th>
	        		<th>Date d\'expiration</th>
	        		<th>&nbsp;</th>
					<th>&nbsp;</th>
	        	</tr>
	        </thead>	
	        <tbody>
	        	'.edit_praticiens_licences($idPrat).'
	        </tbody>
  		</table>
		<br /><br />
  		<table class="table table-striped">
  			<tbody>
  				<tr>
  					<td>Ajouter une licence :</td>
					<td>
  						<select name="typeLic" class="form-control">
	  						'.type_lic().'
	  					</select>
	  				</td>
						<td><button type="submit" name="Aj" class="btn btn-success">Ajouter</button></td>
  				</tr>
  			</tbody>
  		</table>
</form>';
}
else{
	$site->corps = 'Vous ne pouvez pas acc&eacuteder &agrave cette page.';
}
$site->affiche();
?>